Skip to content

Minizinc does not handle empty arguments well #924

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vdijken opened this issue May 21, 2025 · 12 comments
Open

Minizinc does not handle empty arguments well #924

vdijken opened this issue May 21, 2025 · 12 comments

Comments

@vdijken
Copy link

vdijken commented May 21, 2025

When I define my own separators everything is fine, but when I define an empty argument it seems to be skipped. In the past it worked fine. previous scripts which worked fine, now give different results. See the next example.
`$minizinc -a -n 2 2.mzn --soln-sep "%%%%%%%%%%%%%%%%%%%%%%%%%%%" --search-complete-msg "&&&&&&&&&&&&&&&&&&&&"
3 = 1 + 2
%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 = 1 + 3
%%%%%%%%%%%%%%%%%%%%%%%%%%%

$ minizinc -a -n 2 2.mzn --soln-sep "" --search-complete-msg ""
3 = 1 + 2
--search-complete-msg
4 = 1 + 3
--search-complete-msg`

@cyderize cyderize added bug and removed bug labels May 22, 2025
@cyderize
Copy link
Member

Are you using Windows? I think this is actually this bug in PowerShell PowerShell/PowerShell#6280.

The workaround (over than upgrading to PowerShell 7.3 or using any other OS) is to run with --soln-sep `"`" --search-complete-msg `"`" or revert to using old Windows batch CMD.

I'm going to close this now as I don't think this is a bug in MiniZinc, but if you're running into this on a different operating system, please reopen this issue.

@vdijken
Copy link
Author

vdijken commented May 22, 2025

I use Linux Mint latest version. I cannot find any issue on internet with the command line in a the terminal. I also installed Xterm and tried it there. Results are the same. I tried a shell command file and $# (number of arguments) shows then "" is seen as an argument.

@cyderize
Copy link
Member

I haven't been able to reproduce this problem on Ubuntu 24.04 (which I think should behave the same as Linux Mint).

Which method did you use to install MiniZinc?

@cyderize cyderize reopened this May 22, 2025
@vdijken
Copy link
Author

vdijken commented May 22, 2025

Put distribution in some directory, Define alias for minizinc and minizincIDE.

@cyderize
Copy link
Member

Is the issue still present when you directly call the minizinc binary without the alias? (You might have to use --solver chuffed if the Qt libs for Gecode aren't in your LD_LIBRARY_PATH)

@CervEdin
Copy link

Put distribution in some directory, Define alias for minizinc and minizincIDE.

How did you define the alias? Did you put --soln-sep "" in it?

@CervEdin
Copy link

I can repro if I incorrectly set the alias like this alias minizinc="minizinc -a --soln-sep "" --search-complete-msg """
You can fix it by using single quotes when declaring the alias alias minizinc='minizinc -a --soln-sep "" --search-complete-msg ""'

If this is the case, the cause of the issue is how the shell handles quotes, not minizinc

@CervEdin
Copy link

I would probably advice against setting an alias like this, unless you have a very, very good reason for it

@vdijken
Copy link
Author

vdijken commented May 23, 2025

When not using an alias then I get this error, only for the solver cp-sat.
minizinc --solver cp-sat 3.mzn
...t/MiniZinc/bin/fzn-cp-sat: error while loading shared libraries: libabsl_flags_parse.so.2407.0.0: cannot open shared object file: No such file or directory
=====ERROR=====

@CervEdin
Copy link

This error due to a problem with the dynamic linking of the OR-Tools CP-SAT. CP-SAT uses an external dependency, abseil, and it needs to dynamically link the binary during runtime, but it fails to find in the usual places it's looking for it.

I'm not sure how aliasing the command solves this, you didn't share how you alias.
In general, you should be able to run a command in the same way as when using an alias by just writing out the entire alias.
But the issue you're seeing has to do with dynamic linking not working appropriately.

You should be able to fix it by either modifying and exporting the LD_LIBRARY environment variable, or using ldconfig.
I'm by no means an expert in dynamic linking but hopefully it points you in the right direction

@vdijken
Copy link
Author

vdijken commented May 24, 2025

The point is when I define LD_LIBRARY_PATH as described in the manual, nothing else works like mc or gedit.

@cyderize
Copy link
Member

To test the initial problem with the empty arguments, could you run a solver that doesn't require any shared libraries (e.g. --solver chuffed)? Basically given that I can't reproduce this on my Ubuntu installation, it seems likely that whatever method you're using to alias the minizinc command and setup the library paths is what's dropping the blank arguments.

For me, this is what I tried:

wget https://github.com/MiniZinc/MiniZincIDE/releases/download/2.9.3/MiniZincIDE-2.9.3-bundle-linux-x86_64.tgz
tar -xvf MiniZincIDE-2.9.3-bundle-linux-x86_64.tgz
echo "var 1..3: x;" > test.mzn
./MiniZincIDE-2.9.3-bundle-linux-x86_64/bin/minizinc --solver chuffed -a --soln-sep "" --search-complete-msg "" test.mzn

And I got the expected result

x = 3;
x = 2;
x = 1;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants